import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
        int[] arr = {2,3,1};
        Arrays.sort(arr);
       // System.out.println(Arrays.toString(arr));
        int[] arr1 = {1,2,3};

        List<List<Integer>>  ret = new ArrayList<>();
        ret.add(new ArrayList<Integer>(Arrays.asList(1,2,3)));

        System.out.println(ret);



    }

    public static void main22(String[] args) {
        // Press Alt+Enter with your caret at the highlighted text to see how
        // IntelliJ IDEA suggests fixing it.
        System.out.printf("Hello and welcome!");

        // Press Shift+F10 or click the green arrow button in the gutter to run the code.
        for (int i = 1; i <= 5; i++) {

            // Press Shift+F9 to start debugging your code. We have set one breakpoint
            // for you, but you can always add more by pressing Ctrl+F8.
            System.out.println("i = " + i);
        }
    }
}

/*
三数之和
class Solution {
    public List<List<Integer>> threeSum(int[] nums) {
        List<List<Integer>> ret = new ArrayList<>();

        //1.排序
        Arrays.sort(nums);

        //2.固定数字
        int n = nums.length;
        for(int i = 0; i < n ;) {
            if(nums[i] > 0) {
                break;
            }
            int left = i+1;
            int right = n-1;
            int k = -nums[i];
            // 双指针
            while(left < right ) {
                if(nums[left]+nums[right] > k) {
                    right--;
                } else if(nums[left]+nums[right] < k) {
                    left++;
                } else {
                    ret.add(new ArrayList<Integer>(Arrays.asList(nums[i],nums[left],nums[right])));
                    left++;
                    right--;
                    while(left < right && nums[left] == nums[left-1]) {
                        left++;
                    }
                    while(left < right && nums[right] == nums[right+1]) {
                        right--;
                    }
                }
            }
            // 3 去重
            i++;
            while(i < n &&nums[i] == nums[i-1]) {
                i++;
            }
        }
        return ret;
    }
}
 */

/*
有效三角形个数
class Solution {
    public int triangleNumber(int[] nums) {
        Arrays.sort(nums);

        int ret = 0;
        for(int i = nums.length -1 ; i >= 2 ;i--) {
            int left = 0;
            int right = i-1;
            int count = 0;
            while( left < right) {
                if(nums[left] + nums[right] > nums[i]){
                    count +=(right -left);
                    right--;
                } else {
                    left++;
                }
            }
            ret += count;
        }
        return ret ;
    }
}
 */


/*
四数之和
class Solution {
    public List<List<Integer>> fourSum(int[] nums, int target) {
         List<List<Integer>> ret = new ArrayList<>();
         //1. 排序
         Arrays.sort(nums);

         //2. 固定数字
         int n = nums.length;
         for(int i = 0; i< n-1;) {

            int j = i + 1;
            for(;j < n-1; ) {
                int left = j+1;
                int right = n-1;
                long k = target-nums[i];

                while(left < right) {
                    long t = k-nums[j];
                    if(nums[left] + nums[right] > t) {
                        right--;
                    } else if(nums[left] + nums[right] < t) {
                        left++;
                    } else {
                        ret.add(new ArrayList<Integer>(Arrays.asList(nums[i],nums[j],nums[left],nums[right])));
                        left++;
                        right--;
                        while(left<right && nums[left] == nums[left-1]) {
                            left++;
                        }
                        while(left<right && nums[right] == nums[right+1]) {
                            right--;
                        }
                    }
                }
                j++;
                while(j < n-1 && nums[j] == nums[j-1]) {
                    j++;
                }
            }
            i++;
             while(i < n-1 && nums[i] == nums[i-1]) {
                    i++;
                }

         }
         return ret;
    }
}
 */